{include file="head_2" title="代理添加" /}
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header">代理添加</div>
            <div class="layui-card-body" style="padding: 15px;">
                <form id="form" class="layui-form"  method="post" style="width:50%;">
                    <div class="layui-form-item">
                        <label class="layui-form-label">账号：</label>
                        <div class="layui-input-block">
                            <input type="text" name="user" value="" lay-verify="required" autocomplete="off" placeholder="请输入账号" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">姓名：</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" value="" lay-verify="required" autocomplete="off" placeholder="请输入姓名" class="layui-input">
                        </div>
                    </div>
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label">区域</label>
                        <div class="layui-input-block w50">
                            <select lay-filter="level"  lay-verify="required" autocomplete="off" name="a_id" >
                                <option value="">请选择</option>
                                {foreach $rs as $v } 
                                    <option value="{$v.id}">{$v.sheng}{$v.shi}</option>
                                {/foreach}    
                            </select>
                        </div>
                    </div>
                    
                    <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">密码</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="pwd" value="123456"  lay-verify="required" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux"></div>
                            </div>
                        </div>
                    
                    <div class="layui-form-item">
                            <label class="layui-form-label">关联角色：</label>
                            <div class="layui-input-block">
                                {foreach $rules as $v } 
                                    <input type="checkbox" name="rules[]" title="{$v.name}" value='{$v.id}' >
                                {/foreach} 
                            </div>
                    </div>
                    <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">排序</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="sort" value="100" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">值大靠前</div>
                            </div>
                        </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
                            <button type="button" class="layui-btn layui-btn-primary" onclick="javascript:history.back(-1)">返回</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="{$Think.const.admin_tpl}/layui/layui.js"></script>  
    <script>
        layui.config({
            base: '{$Think.const.admin_tpl}/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate'], function () {
            var $ = layui.$
                    , layer = layui.layer
                    , form = layui.form;
                    
            /* 监听提交 */
            form.on('submit(sub)', function (data) {
                $.ajax({
                    url: "/admin/users/dladd/",
                    type: 'post',
                    data: $("#form").serialize(),
                    dataType: 'json',
                    success: function (data) {
                        if(data.status==1)
                        {
                            layer.confirm('操作成功！请选择？', {
                                btn: ['继续添加','返回列表'] //按钮
                              }, function(){
                                  location.reload();
                              }, function(){
                                  location.href = '/admin/users/dlbrowse.html';
                              });
                        }
                        else
                        {
                            layer.msg(data.msg);
                        }
                    },
                    error: function (msg) {
                        alert(" 数据保存失败！" + msg);
                    }
                });
                return false;
            });
        });
    </script>
    </body>
</html>